package com.ruoyi.sl.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.sl.domain.SlWerror;
import com.ruoyi.sl.service.ISlWerrorService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 工作绩效Controller
 * 
 * @author admin
 * @date 2024-06-14
 */
@RestController
@RequestMapping("/sl/werror")
public class SlWerrorController extends BaseController
{
    @Autowired
    private ISlWerrorService slWerrorService;

    /**
     * 查询工作绩效列表
     */
    @PreAuthorize("@ss.hasPermi('sl:werror:list')")
    @GetMapping("/list")
    public TableDataInfo list(SlWerror slWerror)
    {
        startPage();
        List<SlWerror> list = slWerrorService.selectSlWerrorList(slWerror);
        return getDataTable(list);
    }

    /**
     * 导出工作绩效列表
     */
    @PreAuthorize("@ss.hasPermi('sl:werror:export')")
    @Log(title = "工作绩效", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SlWerror slWerror)
    {
        List<SlWerror> list = slWerrorService.selectSlWerrorList(slWerror);
        ExcelUtil<SlWerror> util = new ExcelUtil<SlWerror>(SlWerror.class);
        util.exportExcel(response, list, "工作绩效数据");
    }

    /**
     * 获取工作绩效详细信息
     */
    @PreAuthorize("@ss.hasPermi('sl:werror:query')")
    @GetMapping(value = "/{werrorId}")
    public AjaxResult getInfo(@PathVariable("werrorId") Long werrorId)
    {
        return success(slWerrorService.selectSlWerrorByWerrorId(werrorId));
    }

    /**
     * 新增工作绩效
     */
    @PreAuthorize("@ss.hasPermi('sl:werror:add')")
    @Log(title = "工作绩效", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SlWerror slWerror)
    {
        return toAjax(slWerrorService.insertSlWerror(slWerror));
    }

    /**
     * 修改工作绩效
     */
    @PreAuthorize("@ss.hasPermi('sl:werror:edit')")
    @Log(title = "工作绩效", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SlWerror slWerror)
    {
        return toAjax(slWerrorService.updateSlWerror(slWerror));
    }

    /**
     * 删除工作绩效
     */
    @PreAuthorize("@ss.hasPermi('sl:werror:remove')")
    @Log(title = "工作绩效", businessType = BusinessType.DELETE)
	@DeleteMapping("/{werrorIds}")
    public AjaxResult remove(@PathVariable Long[] werrorIds)
    {
        return toAjax(slWerrorService.deleteSlWerrorByWerrorIds(werrorIds));
    }
}
